<?php
/**
 * Created by PhpStorm.
 * User: teddy
 * Date: 16-1-6
 * Time: 下午12:09
 */


$postvar = $_POST;

$id = $postvar["id"];
$name = $postvar["name"];
$pwd = $postvar["pwd"];

$sql = sprintf("UPDATE `APITEST`.`Users` SET `name` = '%s', `pwd` = '%s' WHERE `id` = '%s'", $name, $pwd, $id);

UpdateData($sql);
echo "1";

function UpdateData($sql)
{
    $mysqli = new mysqli('192.168.2.191','root','pwd','APITEST');
    if (mysqli_connect_errno())
    {
        echo "{" . '"error"' . ":" . mysqli_connect_error() . "}";
    }
    $mysqli->query("set character set 'utf8'");
    $mysqli->query("set names 'utf8'");
    $mysqli->query($sql);
}